var utils = require('./utils');

function replaceCaseInsensitive(str, from , to )
{
	if(str == null || str.length == 0)
		return str;

	 var regex = new RegExp( from, 'gi' );
	 return str.replace( regex, to );
}

module.exports = function(str)
{
	// ios 에서 이 문자 들어간거 에러남.
	if(utils.isValidString(str) && str.indexOf(' ॣ') >=0 )
	{
		var err = new Error('contains prohibited word : ' + str);
		err.code = '999';
		throw err;
	}

// 그 단어만 딱 잘라서 해결할 수 있게 해야 함 - 중간에 나오는건 패스해야함.
/*
	str = replaceCaseInsensitive(str , 'fuck' , 'f**k');
	str = replaceCaseInsensitive(str , 'ass' , 'a*s');
	str = replaceCaseInsensitive(str , 'penis' , 'p***s');
	str = replaceCaseInsensitive(str , 'pussy' , 'p***y');
	str = replaceCaseInsensitive(str , 'vagina' , 'v****a');
	str = replaceCaseInsensitive(str , 'cunt' , 'c**t');
	str = replaceCaseInsensitive(str , 'dick' , 'd**k');
	str = replaceCaseInsensitive(str , 'suck' , 's**k');
	str = replaceCaseInsensitive(str , 'bitch' , 'b***h');
	str = replaceCaseInsensitive(str , 'stupid' , 's****d');
*/
	return str;

}
